package com.allwees.bs.core.modelbase.bo;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * 领域模型基类 - 业务对象类
 *
 * @author yangylsky
 */
public interface Bo extends Comparable<Bo>, Serializable {
	String getUuid();

	Date getCreatedAt();

	Date getUpdatedAt();

	Integer getIdx();

	Integer getStatus();

	Bo setStatus(Integer status);

	@Override
	default int compareTo(Bo bo) {
		return bo == null ? 1 :
				getIdx() == null ? -1 :
						getIdx() > bo.getIdx() ? 1 : -1;
	}

	static <B extends Bo> Set<String> getUuids(Collection<B> bos) {
		Set<String> uuids = new HashSet<>();
		if(bos != null) {
			bos.stream().forEach(bo -> uuids.add(bo.getUuid()));
		}
		return uuids;
	}
}
